﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Windows.Forms;
using BUS;
using DTO;
using DAO;

public partial class Employee_Report : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack == false)
            RadioButton1.Checked = true;
    }

    protected void btnShow_Click(object sender, EventArgs e)
    {
        List<HoaDonDto> danhsach = null;

        if (RadioButton1.Checked == true)
        {
            int thang = int.Parse(CombThang.SelectedValue);
            int nam = int.Parse(CombNam.SelectedValue);

            danhsach = HoaDonBus.layDanhSachHoaDonThang(thang, nam);
        }
        else if (RadioButton2.Checked == true)
        {
            int qui = int.Parse(CombQui.SelectedValue);
            int nam = int.Parse(CombNam.SelectedValue);

            danhsach = HoaDonBus.layDanhSachHoaDonQui(qui, nam);
        }

        dataHoaDon.DataSource = danhsach;
        dataHoaDon.DataBind();

        int doanhthu = 0;
        int tonggiatri = 0;
        for (int i = 0; i < danhsach.Count; i++)
        {
            if (danhsach[i].TinhTrang > 0)
                doanhthu += danhsach[i].GiaTri;
            tonggiatri += danhsach[i].GiaTri;
        }
        // hien thi lable va danh sach bao bieu vua tao ra
        LabelBaobieu.Visible = true;
        dataHoaDon.Visible = true;
        LabeTong.Visible = true;
        LabelDoanhThu.Visible = true;

        DoanhThu.Text = doanhthu.ToString() + " VND";
        TongGiaTri.Text = tonggiatri.ToString() + " VND";
        TongGiaTri.Visible = true;
        DoanhThu.Visible = true;
    }

}
